package com.zhuss.util;

import java.util.List;


public class SiteRange {
	
	public static List<Double> rangeLng(Double km, Double lng) {
		if (km == null) {
			km = 2d;
		}
		if (lng == null || Double.valueOf(lng) < 120d || Double.valueOf(lng) > 122d) {
			lng = 120.978;
		}
		Double start = lng - 0.01d * km / 2;
		Double end = lng + 0.01d * km / 2;
		return new ListBean<Double>().build(start).build(end).getList();
	}
	
	public static List<Double> rangeLat(Double km, Double lat) {
		if (km == null) {
			km = 2d;
		}
		if (lat == null || Double.valueOf(lat) < 30d || Double.valueOf(lat) > 32d) {
			lat = 31.386;
		}
		Double start = lat - 0.01d * km / 2;
		Double end = lat + 0.01d * km / 2;
		return new ListBean<Double>().build(start).build(end).getList();
	}
	
	
	public static String roundLng(String lng) {
		if (lng == null || "".equals(lng.trim()) || Double.valueOf(lng) < 120d || Double.valueOf(lng) > 122d) {
			lng = "120.978";
			lng = "121.0861471830922";
		}
		StringBuilder sub = new StringBuilder("");
		sub.append(lng);
		return sub.toString();
	}
	
	public static String roundLat(String lat) {
		if (lat == null || "".equals(lat.trim()) || Double.valueOf(lat) < 30d || Double.valueOf(lat) > 32d) {
			//lat = "31.386";
			lat = "31.30270721277866";
		}
		StringBuilder sub = new StringBuilder("");
		sub.append(lat);
		return sub.toString();
	}
	
	public static void main(String[] args) {
		System.out.println(roundLng("121.0"));
		System.out.println(roundLat("31.2"));
	}

}
